package ToYesterday.Day15_getTreeHigh_S;

import ToYesterday.Day13_TreeNode.TNode;
import org.junit.Test;

import java.util.ArrayList;

public class All_Path {
    TNode T;
    void init(){
        T = new TNode(2);
        TNode n1 = new TNode(3);
        TNode n2 = new TNode(5);
        TNode n3 = new TNode(6);
        TNode n4 = new TNode(12);
        TNode n5 = new TNode(7);
        T.left = n1;
        T.right = n2;
        n1.left = n3;
        n1.right = n4;
        n2 .right = n5;
    }

    ArrayList<Integer> lists;
    @Test
    public void getAllPath(){
        init();
        lists = new ArrayList<>();
        getPath(T);
    }

    public void getPath(TNode T){
        if (T==null){
            return;
        }
        lists.add(T.val);
        if (T.left==null&&T.right==null){
            for (int i :lists){
                System.out.print(i);
            }
            System.out.println();
        }
        getPath(T.right);
        getPath(T.left);
        lists.remove(lists.size()-1);
    }


}
